const { existsSync, mkdirSync } = require('fs')
const { dirname } = require('path')

/**
 * @description 递归创建文件夹
 * @param {string} path 绝对路径
 */
const createDir = (filepath) => {
  if (existsSync(filepath)) {
    return true
  } else {
    if (createDir(dirname(filepath))) {
      mkdirSync(filepath)
      return true
    }
  }
}

module.exports = {
  createDir
}